package com.yicong.ants.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yicong.ants.R;

/**
 * 选择图片 popupWindow
 */
public class SelectImagePop extends BasePopupWindow {

    private SelectImagePopCall mCallBack;

    public SelectImagePop(Context context) {
        super(context);
        if (context instanceof SelectImagePopCall) {
            mCallBack = (SelectImagePopCall) context;
        }
        initListener();
    }

    @Override
    public void initSetting() {
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        this.setOutsideTouchable(true);
    }

    @Override
    public void initView() {
        mView = LayoutInflater.from(mContext).inflate(R.layout.popup_window_select_image, null);
    }

    @Override
    public void initListener() {
        super.initListener();
        RelativeLayout camera = mView.findViewById(R.id.rel_camera);
        camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != mCallBack) {
                    mCallBack.callCamera();
                }
            }
        });
        RelativeLayout photo = mView.findViewById(R.id.rel_photo);
        photo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != mCallBack) {
                    mCallBack.callPicture();
                }
            }
        });
        TextView cannel = mView.findViewById(R.id.tv_cannel);
        cannel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public interface SelectImagePopCall {
        void callPicture();

        void callCamera();
    }
}
